use gfsc::*;


use clap::Parser;
use dirs::home_dir;

#[derive(Parser, Debug)]
#[clap(
    name = "gfs whereis",
    version,
    author,
    about = "search from gfs"
)]
struct Cli {
    /// 
    #[clap(name = "fname",  default_value = "")]    
    fname: String,    
    /// Sets a router.json
    #[clap(name = "router", short, long, default_value = "~/.rabbit/router.json")]    
    router: String,
}

pub fn main() {
    let mut cli = Cli::parse();
    if cli.router.as_str().eq("~/.rabbit/router.json"){        
        let home =  home_dir().unwrap();
        cli.router = home.join(".rabbit").join("router.json").display().to_string();
    }    
   
    let router = gfsc_new_router(  &cli.router ).unwrap();        
    let f = gfsc_whereis(&router , router.cur_dynasty, &cli.fname);
    let rt = tokio::runtime::Runtime::new().unwrap();
    let r = rt.block_on(f).unwrap();
    println!("{:#?}", r);
    
}
 